#ifndef _MIDI_HPP_
#define _MIDI_HPP_
#include "SoundResource.hpp"
#include <string>
using namespace std;

//////////////////////////////////////////////////////////////////////////
class Midi
{
public:
    Midi(string path);
    ~Midi();

public:
    int GetLength()             const { return m_iLength; }
    int GetCurrentPosition()    const { return midi_time; }    
    int GetLoopStartPosition()  const { return midi_loop_start; } 
    int getLoopEndPosition()    const { return midi_loop_end; }   
    string GetFilename()        const { return m_sFilename; }

public:
    bool IsReady() const;
    bool IsPlaying() const;
    bool IsPaused() const;

public:
    bool Play(bool abLoop = false);
    void Stop();                        // can not fail
    bool Loop(int start, int end);
    bool Pause();
    bool Resume();
    bool Seek(int aiTarget);

private:
    AllegroResource m_oAllegro;
    SoundResource   m_oSound;       // sound resource also depends on allegro resource but there is
                                    // only a small cost for double dependency
private:
    MIDI *  m_pMidi;
    string  m_sFilename;
    int     m_eState;
    int     m_iLength;
};

//////////////////////////////////////////////////////////////////////////
#endif // _MIDI_HPP_
